unit uFrm09Log;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  dxTL, dxDBCtrl, dxDBGrid, dxCntner, ComCtrls, StdCtrls, Buttons, ExtCtrls,
  Db, DBClient;

type
  TFrm09Log = class(TForm)
    PnlTop: TPanel;
    PnlToolBar: TPanel;
    Bevel1: TBevel;
    Bevel2: TBevel;
    SpbtnRefresh: TSpeedButton;
    SpbtnAdd: TSpeedButton;
    SpbtnEdit: TSpeedButton;
    SpbtnDel: TSpeedButton;
    SpbtnSave: TSpeedButton;
    SpbtnCancel: TSpeedButton;
    SpbtnExport: TSpeedButton;
    SpbtnPrint: TSpeedButton;
    SpbtnFirst: TSpeedButton;
    SpbtnPrivor: TSpeedButton;
    SpbtnNext: TSpeedButton;
    SpbtnLast: TSpeedButton;
    SpbtnExit: TSpeedButton;
    SpbtnFind: TSpeedButton;
    Bevel3: TBevel;
    Bevel4: TBevel;
    Bevel5: TBevel;
    Bevel6: TBevel;
    Bevel7: TBevel;
    Panel7: TPanel;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    DTPA: TDateTimePicker;
    DTPB: TDateTimePicker;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    dxDBGrid1: TdxDBGrid;
    dxDBGrid1Column6: TdxDBGridColumn;
    dxDBGrid1Column5: TdxDBGridColumn;
    dxDBGrid1Column4: TdxDBGridColumn;
    dxDBGrid1Column7: TdxDBGridColumn;
    CDSDBA: TClientDataSet;
    DataSource1: TDataSource;
    btnRefresh: TSpeedButton;
    Label2: TLabel;
    edtUser: TEdit;
    Label3: TLabel;
    edtOper: TEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure btnRefreshClick(Sender: TObject);
    procedure SpbtnExitClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frm09Log: TFrm09Log;

implementation
uses uFuntionSys, uFunDx,uDM, uDataSys, uFrm03AddStation;
{$R *.DFM}

procedure TFrm09Log.FormClose(Sender: TObject; var Action: TCloseAction);
begin
   PReadAndSaveFormALL(Self,False);
   Action:=caFree;
end;

procedure TFrm09Log.FormShow(Sender: TObject);
begin
    DTPA.DateTime := now;  DTPB.DateTime := now;
    PReadAndSaveFormALL(Self,true);
    DTPA.DateTime:=dMonthFirst();
    PSetOrderPnlBtn(PnlToolBar);
    PSetToolBarStyle(PnlToolBar,bSYSShowBtnCaption);
end;

procedure TFrm09Log.btnRefreshClick(Sender: TObject);
var
  Str:String;
  args:String;
begin
    Str:='Select T0.* from  TBD06_log T0 where sDateYMD>='''
         + FZDateStr(DTPA.DateTime, false) +
          ''' and sDateYMD<=''' + FZDateStr(DTPB.DateTime, false)
          + '''';

    if edtuser.Text <> '' then begin
       args := args + ' and sUser=''' + edtuser.Text + '''';
    end;

    if edtOper.Text <> '' then begin
       args := args + ' and sType=''' + edtOper.Text + '''';
    end;

    Str := Str + args;

    FCarryOutSQL(CDSDBA,Str,True,False);
    PSetGroupCount(dxDBGrid1);PSetGroupCount(dxDBGrid1);

end;

procedure TFrm09Log.SpbtnExitClick(Sender: TObject);
begin
   Close;
end;

end.
